function get0To255() {
  return Math.round(Math.random() * 255) // 0-255
}
function get1To10() {
  return Math.ceil(Math.random() * 10) // 1-10
}

// 获取随机个banner
export function getBanner(): string[] {
  const data = [];
  const count = get1To10();
  for (let i = 0; i < count; i += 1) {
    data.push(`rgb(${get0To255()},${get0To255()},${get0To255()})`);
  }
  return data
}

// 获取10条数据
type Data = { id: string, text: string }[];
export function getData10(): { reset: () => Data, create: () => Data } {
  let count = 1;
  function create(): Data {
    const data = [];
    for (let i = count; i <= count + 9; i += 1) {
      data.push({
        id: i.toString(),
        text: i.toString()
      });
    }
    count += 10;
    return data
  }
  function reset() {
    count = 1;
    return create();
  }
  return {
    reset,
    create
  }
}
